// ==UserScript==
// @name         电商课每日小结
// @namespace    https://gitee.com/vbox007/Tampermonkey/raw/master/
// @version      1.0.0.18
// @description  我也不想回答那些奇怪的问题，所以别问我怎么做到的
// @author       vbox007
// @icon         
// @match        *shangoue.meituan.com/*
// @match        https://zt.hiboos.com/daily/summary
// @connect      *
// @run-at       document-start
// @grant        GM_xmlhttpRequest
// @grant        GM_getValue
// @grant        GM_setValue
// @grant        GM_deleteValue
// ==/UserScript==

(function () {
    'use strict';
    var $ = function (x) {
        return document.getElementById(x);
    };
    if (window.location.href == 'https://zt.hiboos.com/daily/summary') {
        console.log('挂接网页！！！');
    } else if (window.location.href.indexOf('shangoue.meituan.com') != -1) {
        console.log('***狗日的美团！！！***');
        var mtid = [0, 0];
        for (var i in localStorage) {
            //console.log(localStorage[i]);
            if (typeof (localStorage[i]) == 'string') {
                if (localStorage[i].slice(2, 11) == 'accountId') {
                    mtid[0] = JSON.parse(localStorage[i]).accountId;
                }
                if (localStorage[i].slice(3, 10) == 'wmPoiId') {
                    mtid[1] = JSON.parse(localStorage[i])[0].wmPoiId;
                }
            }
        }
        GM_setValue('mtid', mtid);
        return;
    } else {
        return;
    }
    function getstrtime(difft, c_type, c_one) {
        var nowdate = new Date();
        if (difft) {
            nowdate.setTime(nowdate.getTime() + difft);
        }
        var nowmon = nowdate.getMonth() + 1;
        var strDate = nowdate.getDate();
        if (nowmon >= 1 && nowmon <= 9) {
            nowmon = "0" + nowmon;
        }
        if (strDate >= 0 && strDate <= 9) {
            strDate = "0" + strDate;
        }
        var cdate;
        if (c_type == 1) {
            if (c_one) {
                cdate = '' + nowdate.getFullYear() + nowmon + "01";
            } else {
                cdate = '' + nowdate.getFullYear() + nowmon + strDate;
            }
        } else if (c_type == 2) {
            cdate = nowdate.getFullYear() + '年' + nowmon + '月' + strDate + '日';
        } else {
            cdate = nowdate.getFullYear() + '-' + nowmon + '-' + strDate;
        }
        return cdate;
    }//获取今天的日期文本
    function get_dmall_id() {
        GM_xmlhttpRequest({
            method: "post",
            url: "https://waybillsmartallot-partner.dmall.com/api/getStoreList",
            data: null,
            headers: {
                "accept": "application/json, text/javascript, */*; q=0.01",
                "accept-language": "zh-CN,zh;q=0.9",
                "sec-fetch-dest": "empty",
                "sec-fetch-mode": "cors",
                "sec-fetch-site": "same-site"
            },
            onload: function (res) {
                try {
                    var pobj = JSON.parse(res.responseText);
                    GM_setValue("dmall_id", pobj.data[0].storeId);
                    location.reload();
                } catch (error) {
                    var dsdiv = document.getElementById('dailysummary');
                    dsdiv.innerHTML += '多点来客系统尚未登陆，请确认登陆状态。';
                    console.log('*');
                    console.log(error.message);
                    console.log('*');
                }
            },
            onerror: function (err) {
                var dsdiv = document.getElementById('dailysummary');
                dsdiv.innerHTML += '多点来客系统尚未登陆，请确认登陆状态。';
                console.log('*');
                console.log(err);
                console.log('*');
            }
        });
    }
    function f_dmall(c_pageno) {
        if (c_pageno == -1) {
            $('spdmall').innerText = "ok";
            f_endload();
            return;
        }
        c_pageno = (c_pageno || 1);
        GM_xmlhttpRequest({
            method: "post",
            url: 'https://fulproduce-partner.dmall.com/produceOrderList/list',
            data: 'storeIds=' + GM_getValue("dmall_id", "err") + '&tradeTypes=1&orderPayTimeStart=' + getstrtime() + '+00%3A00%3A00&orderPayTimeEnd=' + getstrtime() + '+23%3A59%3A59&orderStatus=4%2C12%2C9%2C10%2C11%2C13%2C15%2C16%2C17%2C18%2C32%2C33%2C36%2C37%2C64%2C65%2C128%2C133%2C135&pageSize=512&pageNo=' + c_pageno,
            headers: {
                "accept": "application/json, text/javascript, */*; q=0.01",
                "accept-language": "zh-CN,zh;q=0.9",
                "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
                "sec-fetch-dest": "empty",
                "sec-fetch-mode": "cors",
                "sec-fetch-site": "same-site"
            },
            onload: function (res) {
                try {
                    var pobj = JSON.parse(res.responseText);
                    var dmvalue = GM_getValue("dmvalue", [0, 0.0, 0, 0.0]);
                    for (var i = 0; i < pobj.data.data.length; i++) {
                        if (pobj.data.data[i].shipmentTypeDesc == "自提") {
                            dmvalue[2]++;
                            dmvalue[3] += parseFloat(pobj.data.data[i].produce_order__ware_total_price) / 100;
                        } else {
                            dmvalue[0]++;
                            dmvalue[1] += parseFloat(pobj.data.data[i].produce_order__ware_total_price) / 100;
                        }
                    }
                    GM_setValue("dmvalue", dmvalue);
                    if (c_pageno < (parseInt(pobj.data.amount) / 512 + 0.999 >>> 0)) {
                        f_dmall(c_pageno + 1);
                    } else {
                        f_dmall(-1);
                    }
                } catch (error) {
                    $('spdmall').innerText = "error";
                    f_endload();
                }
            },
            onerror: function (err) {
                $('spdmall').innerText = "oerror";
                f_endload();
            }
        });
    }
    function f_mtwm() {
        //poiPrintTemplates
        var mtid = GM_getValue('mtid', [0, 0]);
        GM_xmlhttpRequest({
            method: "get",
            url: "https://waimaieapp.meituan.com/igate/recoanalysis/businessAnalysis/currentMetrics?acctId=" + mtid[0] + "&needRatio=1&source=0&wmPoiId=" + mtid[1],
            data: null,
            headers: {
                "accept": "*/*",
                "accept-language": "zh-CN,zh;q=0.9",
                "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
                "sec-fetch-dest": "empty",
                "sec-fetch-mode": "cors",
                "referrerPolicy": "strict-origin-when-cross-origin",
                "sec-fetch-site": "same-site"
            },
            onload: function (res) {
                try {
                    console.log(res.responseText);
                    var pobj = JSON.parse(res.responseText);
                    console.log(pobj);
                    var mtvalue = [parseInt(pobj.data[1].currentValue), parseFloat(pobj.data[0].currentValue)];
                    GM_setValue("mtvalue", mtvalue);
                    $('spmtwm').innerText = "ok";
                    f_endload();
                } catch (error) {
                    $('spmtwm').innerText = "error";
                    f_endload();
                }
            },
            onerror: function (err) {
                $('spele').innerText = "oerror";
                f_endload();
            }
        });
    }
    function f_ele() {
        GM_xmlhttpRequest({
            method: "get",
            url: 'https://ebai.ele.me/api/dashboard/bussiness/realtime?roleType=1',
            data: null,
            headers: {
                "accept": "*/*",
                "accept-language": "zh-CN,zh;q=0.9",
                "sec-fetch-dest": "empty",
                "sec-fetch-mode": "cors",
                "sec-fetch-site": "same-site"
            },
            onload: function (res) {
                try {
                    var pobj = JSON.parse(res.responseText);
                    var elvalue = [parseInt(pobj.valid_order_num.count), parseFloat(pobj.gmv.count)];
                    GM_setValue("elvalue", elvalue);
                    $('spele').innerText = "ok";
                    f_endload();
                } catch (error) {
                    $('spele').innerText = "error";
                    f_endload();
                }
            },
            onerror: function (err) {
                $('spele').innerText = "oerror";
                f_endload();
            }
        });
    }
    function f_jddj() {
        GM_xmlhttpRequest({
            method: "get",
            url: 'https://store.jddj.com/client?appName=scpc&functionId=%2FgateWay%2FnewHome%2FgetTodayFinishOrderNumAndMoney&body=%7B%7D',
            data: null,
            headers: {
                "accept": "application/json, text/javascript, */*; q=0.01",
                "accept-language": "zh-CN,zh;q=0.9",
                "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
                "sec-fetch-dest": "empty",
                "sec-fetch-mode": "cors",
                "sec-fetch-site": "same-origin",
                "x-requested-with": "XMLHttpRequest"
            },
            onload: function (res) {
                try {
                    var pobj = JSON.parse(res.responseText);
                    var jdvalue = [parseInt(pobj.result.todayFinishOrderNum), parseFloat(pobj.result.todayOrderTurnover)];
                    GM_setValue("jdvalue", jdvalue);
                    $('spjddj').innerText = "ok";
                    f_endload();
                } catch (error) {
                    $('spjddj').innerText = "error";
                    f_endload();
                }
            },
            onerror: function (err) {
                $('spjddj').innerText = "oerror";
                f_endload();
            }
        });
    }
    function f_dmdone(c_pageno) {
        if (c_pageno == -1) {
            $('spdmdone').innerText = "ok";
            f_endload();
            return;
        }
        c_pageno = (c_pageno || 1);
        GM_xmlhttpRequest({
            method: "post",
            url: 'https://fulproduce-partner.dmall.com/produceOrderList/list',
            data: 'storeIds=' + GM_getValue("dmall_id", "err") + '&completeTime=' + getstrtime() + '&orderStatus=64%2C65&pageSize=512&pageNo=' + c_pageno,
            headers: {
                "accept": "application/json, text/javascript, */*; q=0.01",
                "accept-language": "zh-CN,zh;q=0.9",
                "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
                "sec-fetch-dest": "empty",
                "sec-fetch-mode": "cors",
                "sec-fetch-site": "same-site"
            },
            onload: function (res) {
                try {
                    var pobj = JSON.parse(res.responseText);
                    var dmdone = GM_getValue("dmdone", [0, 0.0]);
                    for (var i = 0; i < pobj.data.data.length; i++) {
                        dmdone[0]++;
                        dmdone[1] += parseFloat(pobj.data.data[0].produce_order__ware_total_price) / 100;
                    }
                    GM_setValue("dmdone", dmdone);
                    if (c_pageno < (parseInt(pobj.data.amount) / 512 + 0.999 >>> 0)) {
                        f_dmdone(c_pageno + 1);
                    } else {
                        f_dmdone(-1);
                    }
                } catch (error) {
                    $('spdmdone').innerText = "error";
                    f_endload();
                }
            },
            onerror: function (err) {
                $('spdmdone').innerText = "oerror";
                f_endload();
            }
        });
    }
    function f_hbcancel() {
        fetch("https://zt.hiboos.com/wmsOrder/queryOrderByPage", {
            "headers": {
                "accept": "application/json, text/plain, */*",
                "accept-language": "zh-CN,zh;q=0.9",
                "content-type": "application/x-www-form-urlencoded",
                "sec-fetch-dest": "empty",
                "sec-fetch-mode": "cors",
                "sec-fetch-site": "same-origin"
            },
            "referrer": "https://zt.hiboos.com/index.html",
            "referrerPolicy": "strict-origin-when-cross-origin",
            "body": "body=%7B%22timeRange%22%3A%5B%22" + getstrtime() + "%2000%3A00%3A00%22%2C%22" + getstrtime() + "%2023%3A59%3A59%22%5D%2C%22startTime%22%3A%22" + getstrtime() + "%2000%3A00%3A00%22%2C%22endTime%22%3A%22" + getstrtime() + "%2023%3A59%3A59%22%2C%22timeBegin%22%3A%22" + getstrtime() + "%2000%3A00%3A00%22%2C%22timeEnd%22%3A%22" + getstrtime() + "%2023%3A59%3A59%22%2C%22selectTimeType%22%3A%224%22%2C%22statusSet%22%3A%5B%2270%22%5D%7D&page=%7B%22pageNo%22%3A1%2C%22pageSize%22%3A100%7D",
            "method": "POST",
            "mode": "cors",
            "credentials": "include"
        }).then((res) => res.json()).then(pobj => {
            try {
                var hbcancel = [[], [], [], []];
                if (pobj.result.totalCount) {
                    for (var i = 0; i < pobj.result.resultList.length; i++) {
                        hbcancel[pobj.result.resultList[i].channel].push(pobj.result.resultList[i].daySeq);
                    }
                    for (i = 0; i < 4; i++) {
                        hbcancel[i].sort(function (a, b) { return a - b });
                    }
                }
                GM_setValue("hbcancel", hbcancel);
                $('sphbcancel').innerText = "ok";
                f_endload();
            } catch (error) {
                $('sphbcancel').innerText = "error";
                f_endload();
            }
        }).catch(err => {
            $('sphbcancel').innerText = "oerror";
            f_endload();
        });
    }
    function f_achievement() {
        GM_xmlhttpRequest({
            method: "post",
            url: 'https://marketplus-partner.dmall.com/partner/store/report/achievement/report',
            data: 'metricList=1%2C2%2C3%2C4%2C5%2C11&storeId=' + GM_getValue("dmall_id", "err") + '&startDate=' + getstrtime(0, 1, true) + '&endDate=' + getstrtime(0, 1) + '&current=1&size=1',
            headers: {
                "accept": "application/json, text/javascript, */*; q=0.01",
                "accept-language": "zh-CN,zh;q=0.9",
                "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
                "sec-fetch-dest": "empty",
                "sec-fetch-mode": "cors",
                "sec-fetch-site": "same-site"
            },
            onload: function (res) {
                try {
                    var pobj = JSON.parse(res.responseText);
                    GM_setValue("achievement", parseInt(pobj.data.records[0].val_11));
                    $('spachievement').innerText = "ok";
                    f_endload();
                } catch (error) {
                    $('spachievement').innerText = "error";
                    f_endload();
                }
            },
            onerror: function (err) {
                $('spachievement').innerText = "oerror";
                f_endload();
            }
        });
    }
    function f_dmabsence() {
        GM_xmlhttpRequest({
            method: "post",
            url: 'https://manlack-partner.dmall.com/lack/waitingReplyList',
            data: 'reportStartTime=' + getstrtime() + '&reportEndTime=' + getstrtime() + '&venderId=60&erpStoreId=' + GM_getValue("dmall_id", "err") + '&rows=1&page=1',
            headers: {
                "accept": "application/json, text/javascript, */*; q=0.01",
                "accept-language": "zh-CN,zh;q=0.9",
                "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
                "sec-fetch-dest": "empty",
                "sec-fetch-mode": "cors",
                "sec-fetch-site": "same-site"
            },
            onload: function (res) {
                try {
                    var pobj = JSON.parse(res.responseText);
                    GM_setValue("dmabsence", parseInt(pobj.records) || "0");
                    $('spdmabsence').innerText = "ok";
                    f_endload();
                } catch (error) {
                    $('spdmabsence').innerText = "error";
                    f_endload();
                }
            },
            onerror: function (err) {
                $('spdmabsence').innerText = "oerror";
                f_endload();
            }
        });
    }
    function f_hbabsence() {
        //GM_setValue("hbabsence",hbabsence);
        $('sphbabsence').innerText = "未查询";
        f_endload();
    }
    function f_endload() {
        var v_load = $('spdmall').innerText + $('spmtwm').innerText + $('spele').innerText + $('spjddj').innerText + $('spdmdone').innerText + $('sphbcancel').innerText + $('spachievement').innerText + $('spdmabsence').innerText + $('sphbabsence').innerText;
        //console.log(v_load);
        if (v_load.indexOf("⊗") == -1) {
            $('crreport').removeAttribute("disabled");
        }
    }
    function changehead() {
        var innhead = '<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />\n';
        innhead += '<link rel="shortcut icon" type="image/ico" href="">\n'
        innhead += '<title>电商课每日小结</title>\n';
        innhead += '<style>\n';
        innhead += 'div {';
        innhead += 'overflow:auto;';
        innhead += 'margin: 0 auto;';
        innhead += 'text-align:left;';
        innhead += 'display:inline-block;';
        innhead += '*display:inline;';
        innhead += '*zoom:1;';
        innhead += 'vertical-align:top;';
        innhead += '}\n';
        innhead += '</style>';
        document.head.innerHTML = innhead;//修改html的头部
    }
    function changebody() {
        var innhtml = '<div style="width:100%;text-align:center"><div><div>设置：<HR align=left width=80%color=#987cb9 SIZE=1/>门店：<input id="instore"type="text"size=20/><br/>月拉新目标：<input id="intarget"type="text"size=14/><br/>配送员：<br/>&emsp;周日<input id="incouriers0"type="text"size=20/><br/>&emsp;周一<input id="incouriers1"type="text"size=20/><br/>&emsp;周二<input id="incouriers2"type="text"size=20/><br/>&emsp;周三<input id="incouriers3"type="text"size=20/><br/>&emsp;周四<input id="incouriers4"type="text"size=20/><br/>&emsp;周五<input id="incouriers5"type="text"size=20/><br/>&emsp;周六<input id="incouriers6"type="text"size=20/></div><div><br/><br/>&emsp;<button id="saveBtn"><br/><br/><br/><br/><br/><br/><br/><br/>保存修改<br/><br/><br/><br/><br/><br/><br/><br/></button></div><div>&emsp;&emsp;&emsp;&emsp;</div><div>数据读取：<HR align=left width=80%color=#987cb9 SIZE=1/><button id="loadBtn">加载数据</button><br/>多点：<span id="spdmall">⊗</span><br/>美团：<span id="spmtwm">⊗</span><br/>饿了么：<span id="spele">⊗</span><br/>京东：<span id="spjddj">⊗</span><br/>多点完成：<span id="spdmdone">⊗</span><br/>海博取消：<span id="sphbcancel">⊗</span><br/>多点拉新：<span id="spachievement">⊗</span><br/>多点缺货：<span id="spdmabsence">⊗</span><br/>海博缺货：<span id="sphbabsence">⊗</span><br/><button id="crreport" disabled="disabled">生成小结</button></div><br/><div>电商课班表：<table align="center"border="1"cellspacing="0"><thead><tr><th rowspan="2">人员</th><th colspan="7">班次</th></tr><tr><th>星期日</th><th>星期一</th><th>星期二</th><th>星期三</th><th>星期四</th><th>星期五</th><th>星期六</th></tr></thead><tbody id="tbschedule">';
        for (var i = 0; i < 10; i++) {
            innhtml += '<tr>';
            innhtml += '<td><input type="text" size=8/></td>';
            for (var j = 0; j < 7; j++) {
                innhtml += '<td><input type="text" size=4/></td>';
            }
            innhtml += '</tr>';
        }
        innhtml += '</tbody></table></div></div><div>&emsp;</div><div>报告输出：<HR align=left width=80%color=#987cb9 SIZE=1/><textarea id="dsText" style="width:360px; height: 580px;"></textarea></div>';
        document.body.innerHTML = innhtml;
    }
    function loadgmvalue() {
        var replyConfig = GM_getValue("ds-reply", { "instore": "隔壁店", "intarget": "666", "incouriers": ["无", "无", "无", "无", "无", "无", "无"], "schedule": [["陈文俊", "不上班", "不上班", "不上班", "不上班", "不上班", "不上班", "不上班"], ["", "", "", "", "", "", "", ""], ["", "", "", "", "", "", "", ""], ["", "", "", "", "", "", "", ""], ["", "", "", "", "", "", "", ""], ["", "", "", "", "", "", "", ""], ["", "", "", "", "", "", "", ""], ["", "", "", "", "", "", "", ""], ["", "", "", "", "", "", "", ""], ["", "", "", "", "", "", "", ""]] });
        $("instore").value = replyConfig.instore;
        $("intarget").value = replyConfig.intarget;
        for (var i = 0; i < 7; i++) {
            $("incouriers" + i).value = replyConfig.incouriers[i];
        }
        for (i = 0; i < 10; i++) {
            for (var j = 0; j < 8; j++) {
                $("tbschedule").rows[i].cells[j].getElementsByTagName("input")[0].value = replyConfig.schedule[i][j];
            }
        }
    }
    function delgmvalue(delmtv) {
        GM_deleteValue("dmvalue");
        if (delmtv) {
            GM_deleteValue("mtvalue");
        }
        GM_deleteValue("elvalue");
        GM_deleteValue("jdvalue");
        GM_deleteValue("dmdone");
        GM_deleteValue("hbcancel");
        GM_deleteValue("achievement");
        GM_deleteValue("dmabsence");
        GM_deleteValue("hbabsence");
    }
    changehead();
    changebody();
    loadgmvalue();
    $("saveBtn").addEventListener("click", function () {
        try {
            var replyConfig = { "instore": $("instore").value, "instore": $("instore").value, "intarget": $("intarget").value };
            var incouriers = [];
            for (var i = 0; i < 7; i++) {
                incouriers[i] = $("incouriers" + i).value;
            }
            var schedule = [];
            for (i = 0; i < 10; i++) {
                schedule[i] = [];
                for (var j = 0; j < 8; j++) {
                    schedule[i][j] = $("tbschedule").rows[i].cells[j].getElementsByTagName("input")[0].value;
                }
            }
            replyConfig["incouriers"] = incouriers;
            replyConfig["schedule"] = schedule;
            GM_setValue("ds-reply", replyConfig);
            alert("修改成功");
        } catch (err) {
            alert("修改失败");
        }
    });
    $("loadBtn").addEventListener("click", function () {
        $('crreport').setAttribute("disabled", "disabled");
        delgmvalue();
        f_dmall();
        f_mtwm();
        f_ele();
        f_jddj();
        f_dmdone();
        f_hbcancel();
        f_achievement();
        f_dmabsence();
        f_hbabsence();
    });
    $("crreport").addEventListener("click", function () {
        var dmvalue = GM_getValue("dmvalue", [0, 0, 0, 0]);
        var mtvalue = GM_getValue("mtvalue", [0, 0]);
        var elvalue = GM_getValue("elvalue", [0, 0]);
        var jdvalue = GM_getValue("jdvalue", [0, 0]);
        var dmdone = GM_getValue("dmdone", [0, 0]);
        var hbcancel = GM_getValue("hbcancel", [[], [], [], []]);
        var achievement = GM_getValue("achievement", 0);
        var dmabsence = GM_getValue("dmabsence", 0);
        var hbabsence = GM_getValue("hbabsence", 0);
        delgmvalue(1);
        var replyConfig = GM_getValue("ds-reply", { "instore": "隔壁店", "intarget": "666", "incouriers": ["无", "无", "无", "无", "无", "无", "无"], "schedule": [["陈文俊", "不上班", "不上班", "不上班", "不上班", "不上班", "不上班", "不上班"], ["", "", "", "", "", "", "", ""], ["", "", "", "", "", "", "", ""], ["", "", "", "", "", "", "", ""], ["", "", "", "", "", "", "", ""], ["", "", "", "", "", "", "", ""], ["", "", "", "", "", "", "", ""], ["", "", "", "", "", "", "", ""], ["", "", "", "", "", "", "", ""], ["", "", "", "", "", "", "", ""]] });
        var alloperating = [0, 0];
        alloperating[0] = dmvalue[0] + dmvalue[2] + mtvalue[0] + elvalue[0] + jdvalue[0];
        alloperating[1] = dmvalue[1] + dmvalue[3] + mtvalue[1] + elvalue[1] + jdvalue[1];
        var daily_summary = replyConfig.instore + getstrtime(0, 2) + '电商工作总结\n1.今日订单(全平台) ：' + alloperating[0] + '单\n总营业额' + alloperating[1].toFixed(2) + '元。\n';
        if (dmvalue[0] > 0) {
            daily_summary += '    多点订单(o2o):' + dmvalue[0] + '单\n    销售额:' + dmvalue[1].toFixed(2) + '元\n';
        }
        if (dmvalue[2] > 0) {
            daily_summary += '    多点自提:' + dmvalue[2] + '单\n    销售额:' + dmvalue[3].toFixed(2) + '元\n';
        }
        if (mtvalue[0] > 0) {
            daily_summary += '    美团订单：' + mtvalue[0] + '单\n    营业额：' + mtvalue[1].toFixed(2) + '元\n';
        }
        if (elvalue[0] > 0) {
            daily_summary += '    饿了么订单: ' + elvalue[0] + '单\n    营业额：' + elvalue[1].toFixed(2) + '元\n';
        }
        if (jdvalue[0] > 0) {
            daily_summary += '    京东到家订单：' + jdvalue[0] + '单\n    营业额：' + jdvalue[1].toFixed(2) + '元\n';
        }
        alloperating[0] = dmdone[0] + mtvalue[0] + elvalue[0] + jdvalue[0];
        alloperating[1] = hbcancel[0].length + hbcancel[1].length + hbcancel[2].length + hbcancel[3].length;
        daily_summary += '2.今日履约完成' + alloperating[0] + '单，取消订单';
        if (alloperating[1]) {
            daily_summary += alloperating[1] + '单(';
            var zttext = ['WTF', '京东', '美团', '饿了么'];
            for (var i = 0; i < 4; i++) {
                for (var j = 0; j < hbcancel[i].length; j++) {
                    daily_summary += zttext[i] + '#' + hbcancel[i][j] + ',';
                }
            }
            daily_summary = daily_summary.slice(0, -1) + ')\n';
        } else {
            daily_summary += '0单\n';
        }
        daily_summary += '3.本月拉新目标：' + replyConfig.intarget + '人，截至昨日拉新' + achievement + '人 ，完成率:' + (achievement * 100 / replyConfig.intarget).toFixed(2) + '%\n';
        daily_summary += '4.今日缺品：' + dmabsence + '个\n';
        daily_summary += '5.客诉工单：0单\n';
        daily_summary += '6.售后退款情况：0单\n';
        daily_summary += '7.配送系统：';
        var ndg = new Date().getDay();
        if (replyConfig.incouriers[ndg] != '无' && replyConfig.incouriers[ndg]) {
            daily_summary += '多点 ';
        }
        if (jdvalue[0] > 0) {
            daily_summary += '京东到家 ';
        }
        if (mtvalue[0] > 0) {
            daily_summary += '美团 ';
        }
        if (elvalue[0] > 0) {
            daily_summary += '饿了么 ';
        }
        daily_summary += '\n';
        if (replyConfig.incouriers[ndg] != '无' && replyConfig.incouriers[ndg]) {
            daily_summary += '8.今日配送员人数: ';
            var incouriers = 1;
            for (var k = 0; k < replyConfig.incouriers[ndg].length; k++) {
                if (replyConfig.incouriers[ndg][k] == ',' || replyConfig.incouriers[ndg][k] == '，') {
                    incouriers++
                }
            };
            daily_summary += incouriers + '人(' + replyConfig.incouriers[ndg] + ')\n';
        } else {
            daily_summary += '8.今日配送员人数: 0人\n';
        }
        var schedule = replyConfig.schedule;
        daily_summary += '9.今日工作安排:\n';
        var sclass = {};
        ndg++;
        for (var s = 0; s < 10; s++) {
            if (schedule[s][0]) {
                sclass[schedule[s][ndg]] = (sclass[schedule[s][ndg]] ? sclass[schedule[s][ndg]] : '') + schedule[s][0] + '、';
            }
        }
        for (s in sclass) {
            if (s != '' && s != '休') {
                daily_summary += '    ' + s + '：' + sclass[s].slice(0, -1) + '\n';
            }
        }
        daily_summary += '10.明日人员安排：\n';
        sclass = {};
        ndg = ndg % 7 + 1;
        for (s = 0; s < 10; s++) {
            if (schedule[s][0]) {
                sclass[schedule[s][ndg]] = (sclass[schedule[s][ndg]] ? sclass[schedule[s][ndg]] : '') + schedule[s][0] + '、';
            }
        }
        for (s in sclass) {
            if (s != '' && s != '休' && s != '外出') {
                daily_summary += '    ' + s + '：' + sclass[s].slice(0, -1) + '\n';
            }
        }
        daily_summary += '11.今日配送订单是否闭环；是\n';
        daily_summary += '12.如有取消订单请写明原因:0单缺货，其余' + alloperating[1] + '单顾客无理由取消订单；\n';
        daily_summary += '13.本月拉新目标：' + replyConfig.intarget + '人，截至昨日拉新' + achievement + '人 ，完成率:' + (achievement * 100 / replyConfig.intarget).toFixed(2) + '%\n';
        $('dsText').value = daily_summary;
        $('crreport').setAttribute("disabled", "disabled");
    });
    if (GM_getValue("dmall_id", "err") == "err") {
        get_dmall_id();
    }
    //delgmvalue();
    // Your code here...
})();